<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>arthas知识 | 雁过留声</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="#热更新类 #下载源码 script1jad --source-only com.example.demo.arthas.user.UserController &gt; &#x2F;tmp&#x2F;UserController.java   模糊搜索类script1sc *HelloService* 打印类详细信息 -f 打印成员变量信息script12sc -d com.yanglf.mytask.contro">
<meta property="og:type" content="article">
<meta property="og:title" content="arthas知识">
<meta property="og:url" content="http://yanglf007.gitee.io/blog/2020/05/31/arthas%E7%9F%A5%E8%AF%86/index.html">
<meta property="og:site_name" content="雁过留声">
<meta property="og:description" content="#热更新类 #下载源码 script1jad --source-only com.example.demo.arthas.user.UserController &gt; &#x2F;tmp&#x2F;UserController.java   模糊搜索类script1sc *HelloService* 打印类详细信息 -f 打印成员变量信息script12sc -d com.yanglf.mytask.contro">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2020-05-30T17:49:49.739Z">
<meta property="article:modified_time" content="2020-10-11T15:03:45.790Z">
<meta property="article:author" content="yanglf007">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/blog/atom.xml" title="雁过留声" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/blog/css/style.css">

<meta name="generator" content="Hexo 4.2.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/blog/" id="logo">雁过留声</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/blog/">Home</a>
        
          <a class="main-nav-link" href="/blog/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/blog/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yanglf007.gitee.io/blog"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-arthas知识" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2020/05/31/arthas%E7%9F%A5%E8%AF%86/" class="article-date">
  <time datetime="2020-05-30T17:49:49.739Z" itemprop="datePublished">2020-05-31</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      arthas知识
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>#热更新类</p>
<p>#下载源码</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">jad --source-only com.example.demo.arthas.user.UserController &gt; /tmp/UserController.java</span><br></pre></td></tr></table></figure>


<h1 id="模糊搜索类"><a href="#模糊搜索类" class="headerlink" title="模糊搜索类"></a>模糊搜索类</h1><figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sc *HelloService*</span><br></pre></td></tr></table></figure>
<h1 id="打印类详细信息-f-打印成员变量信息"><a href="#打印类详细信息-f-打印成员变量信息" class="headerlink" title="打印类详细信息 -f 打印成员变量信息"></a>打印类详细信息 -f 打印成员变量信息</h1><figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sc -d com.yanglf.mytask.controller.HelloController</span><br><span class="line">sc -d -f com.yanglf.mytask.controller.HelloController</span><br></pre></td></tr></table></figure>

<p>#编译修改后的文件</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mc /tmp/UserController.java -d /tmp</span><br></pre></td></tr></table></figure>
<p>#重新加载类</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">redefine /tmp/com/example/demo/arthas/user/UserController.class</span><br></pre></td></tr></table></figure>

<p>#查超时问题</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">trace com.cainiao.cam.business.web.excel.ExcelController download  '#cost &gt; 10'</span><br></pre></td></tr></table></figure>

<p>#热更新类</p>
<p>#下载源码</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">jad --source-only com.example.demo.arthas.user.UserController &gt; /tmp/UserController.java</span><br></pre></td></tr></table></figure>
<p>#编译修改后的文件</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mc /tmp/UserController.java -d /tmp</span><br></pre></td></tr></table></figure>
<p>#重新加载类</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">redefine /tmp/com/example/demo/arthas/user/UserController.class</span><br></pre></td></tr></table></figure>

<p>#查超时问题</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">trace com.cainiao.cam.business.web.excel.ExcelController download  '#cost &gt; 10'</span><br></pre></td></tr></table></figure>

<h1 id="查看入参出参"><a href="#查看入参出参" class="headerlink" title="查看入参出参"></a>查看入参出参</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">watch com.yanglf.hello.controller.HelloController say &quot;&#123;params,returnObj&#125;&quot; -x 2</span><br></pre></td></tr></table></figure>
<p>monitor -c 5 com.sz.Test test<br>watch com.sz.Test test “{params,returnObj}” “params[1]==5” -x 3<br>watch com.sz.Test test “{params[0],throwExp}” -e -x 2</p>
<h1 id="查看入参出参-1"><a href="#查看入参出参-1" class="headerlink" title="查看入参出参"></a>查看入参出参</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">watch com.yanglf.hello.controller.HelloController say &quot;&#123;params,returnObj&#125;&quot; -x 2</span><br></pre></td></tr></table></figure>

<p>tt -t 进行现场记录</p>
<p>tt -i index 回放</p>
<p>tt -i index -p 重新调用一次 （–replay-times,–replay-interval）</p>
<h1 id="打印方法调用堆栈"><a href="#打印方法调用堆栈" class="headerlink" title="打印方法调用堆栈"></a>打印方法调用堆栈</h1><p>stack com.yanglf.mytask.controller.HelloController#sayHello2</p>
<h2 id="ognl表达式过滤"><a href="#ognl表达式过滤" class="headerlink" title="ognl表达式过滤"></a>ognl表达式过滤</h2><p>stack com.yanglf.mytask.controller.HelloController sayHello2 ‘params[0].equals(“yanglf”)’</p>
<h2 id="根据日志级别"><a href="#根据日志级别" class="headerlink" title="根据日志级别"></a>根据日志级别</h2><p> logger –name ROOT –level debug<br> 或者 logger -c 类加载器hashcode –name ROOT –level debug<br> 类加载器hashcode 可以通过 sc -d 获取<br>ognl ‘@org.springframework.util.StringUtils.replace(“yanglf007”,”007”)’</p>
<p>ognl 调用静态方法</p>
<p>ognl -c 31cefde0 ‘@org.springframework.util.StringUtils@delete(“yanglf007”,”007”)’</p>
<p>sm 查看类方法信息<br>sm -d <em>HelloController</em></p>
<p>dump 类名<br>导出类class文件</p>
<p>heapdump 导出 堆内存</p>
<p>tt 获取任意bean,并且执行方法<br>tt -t org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter invokeHandlerMethod<br>tt -i 1001 -w ‘target.getApplicationContext().getBean(“helloController”).sayHello()’</p>
<p>tt -l 查看tt内容<br>tt 过滤<br>tt -s ‘method.name==”sayHello2”‘</p>
<p>解决方法重载</p>
<p>tt -t *Test print params.length==1</p>
<p>通过制定参数个数的形式解决不同的方法签名，如果参数个数一样，你还可以这样写</p>
<p>tt -t *Test print ‘params[1] instanceof Integer’</p>
<p>解决指定参数</p>
<p>tt -t *Test print params[0].mobile==”13989838402”</p>
<p>构成条件表达式的 Advice 对象</p>
<p>前边看到了很多条件表达式中，都使用了 params[0]，有关这个变量的介绍，请参考表达式核心变量</p>
<p>watch com.chengjf.snippet.spring.mvc.service.HelloService sayHello “{target.clear()}” -x 10 -n 1</p>
<h2 id="tt调用方法-复杂对象时可以转换成字符串处理"><a href="#tt调用方法-复杂对象时可以转换成字符串处理" class="headerlink" title="tt调用方法,复杂对象时可以转换成字符串处理"></a>tt调用方法,复杂对象时可以转换成字符串处理</h2><p>tt -i 1000 -w ‘target.getApplicationContext().getBean(“weChatServiceImpl”).sendMessage(“{&quot;content&quot;:&quot;content&quot;,&quot;recipient&quot;:&quot;recipient&quot;,&quot;subject&quot;:&quot;subject6&quot;}”)’</p>
<h2 id="获取静态变量属性值"><a href="#获取静态变量属性值" class="headerlink" title="获取静态变量属性值"></a>获取静态变量属性值</h2><p>getstatic com.kuaidizs.general.common.nacos.NacosConfigConstant  SWITCH_LIMIT_STATUS</p>
<h2 id="ognl-直接-调用静态方法"><a href="#ognl-直接-调用静态方法" class="headerlink" title="ognl 直接 调用静态方法"></a>ognl 直接 调用静态方法</h2><p>ognl -c 45934fa0  ‘@com.kuaidizs.general.api.common.MallCommonConfig@isProd()’</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yanglf007.gitee.io/blog/2020/05/31/arthas%E7%9F%A5%E8%AF%86/" data-id="ckgtnonlv0001m8ulerj9625e" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/blog/2020/05/31/%E5%86%85%E9%83%A8%E7%A9%BF%E9%80%8F/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          内部穿透
        
      </div>
    </a>
  
  
    <a href="/blog/2020/05/30/redis%E7%9F%A5%E8%AF%86/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">redis知识</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/10/">October 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/08/">August 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/07/">July 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/06/">June 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/05/">May 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/04/">April 2020</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/blog/2020/10/25/%E6%AF%8F%E6%97%A5%E5%AD%A6%E4%B9%A0/">每日学习</a>
          </li>
        
          <li>
            <a href="/blog/2020/10/12/mybatis-plus/">mybatis-plus</a>
          </li>
        
          <li>
            <a href="/blog/2020/08/30/%E7%A7%92%E6%9D%80%E7%B3%BB%E7%BB%9F/">秒杀系统</a>
          </li>
        
          <li>
            <a href="/blog/2020/08/29/elasticsearch%E7%9F%A5%E8%AF%86/">elasticsearch知识</a>
          </li>
        
          <li>
            <a href="/blog/2020/08/28/redis%E9%9D%A2%E8%AF%95/">redis面试</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 yanglf007<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/blog/" class="mobile-nav-link">Home</a>
  
    <a href="/blog/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/blog/fancybox/jquery.fancybox.css">

  
<script src="/blog/fancybox/jquery.fancybox.pack.js"></script>




<script src="/blog/js/script.js"></script>




  </div>
</body>
</html>